{% extends "layout.html" %} {% block body %}
<script>
	function add() {
		window.location.href = "agregarAtributoTipo?filtro=" + document.form.filtro.value +"&idfase="+ document.form.idfase.value+"&idtipoitem="+ document.form.idtipoitem.value;
	}
	function del() {
		var valor;
		var filtro = document.form.filtro.value;

		if (document.form.check.value != null && document.form.check.checked) {
			valor = document.form.check.value;
		} else {
			for (i = 0; i < document.form.check.length; i++) {
				if (document.form.check[i].checked) {
					valor = document.form.check[i].value;
				}
			}
		}
		if (valor != null) {
			window.location.href = "eliminarAtributoTipo?idatributotipo=" + valor
				+ "&filtro=" + filtro +"&idfase="+ document.form.idfase.value;			
		} else {
			alert('Seleccionar un atributo tipo');
		}
	}
</script>
<body>
	<center>
		<div class="titulorojo">GESTIONAR ATRIBUTO TIPO</div>
	</center>
	<center>
		<form name="form" method="POST" action="agregarAtributoTipo">
			<input type="hidden" name="idtipoitem" value="{{ idtipoitem }}">
			<input type="hidden" name="idfase" value="{{ idfase }}">
			<input type="hidden" name="filtro" value="{{ filtro }}">
			<table>
				<tr>
				{% if '00047' in session["permisos"] %}
					<td><button type="button" onClick="add()">
							<img src="{{ url_for('static', filename='add.png') }}">
						</button></td>
				{% endif %}
				{% if '00048' in session["permisos"] %}
					<td><button type="button" onClick="del()">
							<img src="{{ url_for('static', filename='delete.png') }}">
						</button></td>
				{% endif %}
				</tr>
			</table>
			<br>
			<table id="tabla" name="tabla" border=1 cellpadding=2 cellspacing=1
				width=60% align=center bgcolor=#E5E5E5>
				<tr>
					<th class=titulochico width='30%'>Nombre</th>
					<th class=titulochico width='30%'>Descripcion</th>
					<th class=titulochico width='10%'>Marcar</th>
				</tr>
				{% for tipo in lista : %}
				<tr>
				<td align=center>{{ tipo.nombre }}</td>
				<td align=center>{{ tipo.descripcion }}</td>
				<td align=center><input type="radio" name="check"
					value="{{ tipo.idtipoitem }}"></td>
				</tr>
				{% endfor %}
			</table>
		</form>
	</center>
</body>
{% endblock body %}
